package dev.android.yeqh.iask_sina;

import java.util.List;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ListView;
import dev.android.yeqh.iask_sina.adapter.ItemDetailAdapter;
import dev.android.yeqh.iask_sina.common.Constants;
import dev.android.yeqh.iask_sina.common.NetTask;
import dev.android.yeqh.iask_sina.common.Utils;
import dev.android.yeqh.iask_sina.model.NetTaskParam;

public class ItemDetailActivity extends BaseActivity {
	EditText edtKeyword = null;
	ListView lstDetail = null;
	ItemDetailAdapter adapter = null;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.detail);
        
        edtKeyword = (EditText)findViewById(R.id.txt_keyword);
        lstDetail = (ListView)findViewById(R.id.lst_detail);
        
        String key = getIntent().getStringExtra("title");
        new NetTask(this, true).execute(new NetTaskParam(Constants.TYPE_SHOW_DETAIL, new Object[] {key, 1}));
    }
    
    @SuppressWarnings("unchecked")
	@Override
    public void updateUI(Object result) {
    	try {
    		if (result instanceof Exception) {
    			Utils.showMessage(this, (Exception)result);
    			return;
    		}
    		List<String> results = (List<String>)result;
    		adapter = new ItemDetailAdapter(this, results, R.layout.item_detail);
            lstDetail.setAdapter(adapter);
    	} catch (Exception e) {
			Utils.showMessage(this, e);
		}
    	super.updateUI(result);
    }
}